/*
 * @(#)HexFinder.java		       Project:CrackPswd
 * Date:2013-3-31
 *
 * Copyright (c) 2013 CFuture09, Institute of Software, 
 * Guangdong Ocean University, Zhanjiang, GuangDong, China.
 * All rights reserved.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.sinaapp.msdxblog.androidsecurity;

import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;

/**
 * @Author Geek_Soledad (66704238@51uc.com)
 * @Function
 */
public class HexFinder {
	public static String format(byte[] bt) {
		StringBuilder buf = new StringBuilder();
		for (byte d : bt) {
			buf.append(String.format("%02x  ", d));
		}
		return buf.toString();
	}

	public static byte[] readFile(String file) throws IOException {
		InputStream is = new FileInputStream(file);
		int length = is.available();
		byte bt[] = new byte[length];
		is.read(bt);
		return bt;
	}

	public static void main(String[] agrs) throws IOException {
		byte[] bt = HexFinder.readFile("d:\\gesture.key");
		String hexData = HexFinder.format(bt);
		System.out.println(hexData);
	}
}
